package com.WOWTradeNews.phone;

import com.WOWTradeNewsTest.R;
import com.WOWTradeNews.Utils;
import com.WOWTradeNews.services.Mail;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Paint;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.SimpleAdapter.ViewBinder;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class HelpBack extends Activity implements OnClickListener{
	private final String HELP_URL = "http://www.google.com.hk";
	private Button backButton;
	
	private TextView help;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.help_back);
		
		backButton = (Button) findViewById(R.id.back);
        backButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		help = (TextView) findViewById(R.id.help_help);
		help.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
		help.setOnClickListener(this);
		
		Button send = (Button) findViewById(R.id.help_ok);
		send.setOnClickListener(this);
		Button cancel = (Button) findViewById(R.id.help_cancel);
		cancel.setOnClickListener(this);
		
	}
	@Override
	public void onClick(View view) {
		int id = view.getId();
		switch (id) {
		case R.id.help_help:
			Intent it = new Intent(this, HelpDetail.class);
			Bundle bundle = new Bundle();
			bundle.putString("url", HELP_URL);
			it.putExtras(bundle);
			startActivity(it);
			break;
		case R.id.help_ok:
			if(!Utils.isConnect(HelpBack.this)) {
				Dialog.showDialog(HelpBack.this, "目前為無網路狀態");
				break;
			}
			EditText email = (EditText) findViewById(R.id.help_email);
			String e = email.getText().toString();
			EditText content = (EditText) findViewById(R.id.help_content);
			String c = content.getText().toString();
			Mail.sendMailByIntent(HelpBack.this, new String[]{"0805dezhi@gmail.com"}, "內容:" + c + "  \n地址:" + e);
			//Toast.makeText(HelpBack.this, "test", 0).show();
			break;
		case R.id.help_cancel:
			finish();
			break;

		default:
			break;
		}
	}
}
